<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>title</title>
    <script src="https://cdn.staticfile.net/jquery/1.10.2/jquery.min.js"></script>
    <script src="/js/env.js"></script>
    <script>
        $(function () {
            // 登录
            $("#login").click(async function () {
                const username = $("#username").val()
                const password = $("#password").val()
                console.log({username, password})
                const res = await $.ajax({
                    url: `/login`,
                    contentType: "application/json",
                    type: "POST",
                    data: JSON.stringify({username, password})
                })
                console.log(res)
                if (res.code == 200) {
                    localStorage.setItem("username", username)
                    location.href = `/index`
                } else {
                    alert(res.message)
                }
            })
        })
    </script>
</head>
<body>
<div style="position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);">
    <input id="username" name="username" type="text" placeholder="用户名"> <br>
    <input id="password" name="password" type="password" placeholder="密码"> <br>
    <button id="login" type="submit">登录</button>
</div>
</body>
</html>